<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
	exports.get = function(req,res,next){//查询
		var id = req.params.id;//?用的是req.query /用的是req.params  post用的是req.body
		var ids = [];

		DataModel.findOne({_id: id},function(err,doc){
			if(doc){
				doc.getChildren().then(function(docs){//找到它下面所有的子节点

					for(var i=0;i<docs.length;i++){
						ids.push(docs[i]._id);
					}

					DataModel.get({ _id : {$in : ids}})
						.then(data=>{
						res.json(data);
				})

				});
			}
		})
		console.log(ids)
	}
</script>
</body>
</html>


{id:'jioji',
    children:[{
            id:'1123',
            children[
                    {id:'1123',
                    children[{},{},{]]
                    },
                    {id:'1123',
                    children[{},{},{]]
                    }]
            }]
}